﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Site.Master" AutoEventWireup="true" CodeBehind="RoleAdd.aspx.cs" Inherits="VK.Casemeet.Web.Admin.Employees.RoleAdd" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentHead" runat="server">
    <script type="text/javascript">
        $("document").ready(function () {
            if (<% =area1 %> == 0) {
                BindArea(0, "#ddlArea1", 0, 0);
            } else {
                BindArea(0, "#ddlArea1", <% =area1 %>, <% =area2 %>);
            }
        });

        function BindArea(parentID, ddlControl, area1, area2) {
            $.ajax({
                type: "post",
                url: "/Admin/CommService.asmx/GetArea",
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                data: "{ \"parentID\":" + parentID + " }",
                beforeSend: function (jsonHttpRequest) {
                    this;
                },
                success: function (jsonHttpRequest, textStatus) {
                    var temp_option = new String;
                    temp_option += "<option value=\"0\">全部</option>";
                    if (ddlControl == "#ddlArea1") { temp_option = fillOption(temp_option, jsonHttpRequest, area1); }
                    if (ddlControl == "#ddlArea2" && parentID != "0") { temp_option = fillOption(temp_option, jsonHttpRequest, area2); }
                    $(ddlControl).html(temp_option);
                    if (ddlControl == "#ddlArea1") {
                        BindArea($(ddlControl).val(), "#ddlArea2", area1, area2);
                    }
                },
                error: function (jsonHttpRequest, textStatus, errorThrown) {
                    this;
                },
                complete: function (jsonHttpRequest, textStatus) {
                    this;
                }
            });
        }
        function area1_onchange() {
            if ($("#ddlArea1").val() != "0") {
                $("#ddlArea2").html("");
                $("#hidArea").val($("#ddlArea1")[0].options[$("#ddlArea1")[0].selectedIndex].text);
                BindArea($("#ddlArea1").val(), "#ddlArea2", 0, 0, 0);
            }
        }
        function area2_onchange() {
            if ($("#ddlArea2").val() != "0") {
                $("#hidArea").val($("#ddlArea1")[0].options[$("#ddlArea1")[0].selectedIndex].text + " " + $("#ddlArea2")[0].options[$("#ddlArea2")[0].selectedIndex].text);
            }
        }
        function fillOption(temp_option, jsonHttpRequest, area) {
            $.each(jsonHttpRequest.d, function (i, field) {
                if (area == field.AreaID) {
                    temp_option += "<option selected value=\"" + field.AreaID + "\">" + field.Name + "</option>";
                } else {
                    temp_option += "<option value=\"" + field.AreaID + "\">" + field.Name + "</option>";
                }
            });
            return temp_option;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentBody" runat="server">
    <div class="bodyContent divBody">
        <div class="divDetailOper">
            <asp:LinkButton ID="LinkButton1" runat="server" CssClass="butSave" onclick="butSave_Click" OnClientClick="return validator.form();">保存信息</asp:LinkButton>
            <a class="butBack" href="RoleList.aspx">返回列表</a>
        </div>
        <div class="divEdit" style="width:98%;margin:10px 0 0 1%;_margin:10px 0 0 0.5%;height:auto;">
            <div class="title">基本信息</div>
            <div class="content">
                <table class="tableLeftEdit" cellpadding="0" cellspacing="0">
                    <tbody>
                    <tr>
                        <th>名称:</th><td><asp:TextBox ID="txtName" runat="server" 
                            CssClass="inputText required" Width="400px" MaxLength="20"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th>管辖区：</th>
                        <td>
                            <select id="ddlArea1" name="ddlArea1" onchange="area1_onchange();" class="selectddl" style="width:auto;"></select>
		                    <select id="ddlArea2" name="ddlArea2" onchange="area2_onchange();" class="selectddl" style="width:auto;"></select>
                        </td>
                    </tr>
                    <tr>
                        <th>权限:</th>
                        <td>
                            <div style="width:600px;">
                            <asp:Repeater ID="rptRights" runat="server">
                            <HeaderTemplate></HeaderTemplate>
                            <ItemTemplate>
                                <%# (group != (int)Eval("Group")) ? "<div class='clear' style='border-bottom:1px solid #efefef;height:10px;margin:0 0 10px 0px'></div>" : ""%>
                                <div class="left" style="width:200px;line-height:24px;line-height:24px;">
                                    <input id="chkRights<%# Eval("RightsID") %>" name="chkRights" class="radio" type="checkbox" value='<%# Eval("RightsID") %>' <%# bool.Parse(Eval("IsHas").ToString())==true?"checked='checked'":"" %> /><label for="chkRights<%# Eval("RightsID") %>"><%# Eval("Name") %></label>
                                </div>
                                <span class="disn"><%# (group = (int)Eval("Group")) %></span>
                            </ItemTemplate>
                            <FooterTemplate></FooterTemplate>
                            </asp:Repeater>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="clear f0" style="height:10px; width:100%"></div>
        <div class="clear divDetailOper">
            <asp:LinkButton ID="LinkButton2" runat="server" CssClass="butSave" onclick="butSave_Click" OnClientClick="return validator.form();">保存信息</asp:LinkButton>
            <a class="butBack" href="RoleList.aspx">返回列表</a>
        </div>
        <div class="clear f0" style="height:20px;width:100%"></div>
    </div>
</asp:Content>
